<extend name="Public/base"/>
<block name="body">
    <div class="main-title">
        <h2>用户管理</h2>
    </div>
    <style>
        .fr span{}
    </style>
<div class="search-form fr cf">
    <div class="sleft">
        <div class="drop-down">
            <span id="sch-sort-txt" class="sort-txt" data="{$status}"><if condition="get_status_title($status) eq ''">昵称<else/>{:get_status_title($status)}</if></span>
            <i class="arrow arrow-down"></i>
            <ul id="sub-sch-menu" class="nav-list hidden">
                <li><a href="javascript:;" value="2">昵称</a></li>
                <li><a href="javascript:;" value="0">手机号</a></li>
            </ul>
        </div>
        <input type="text" name="title" class="search-input"  id="campus" value="{:I('title')}" placeholder="请输入学生姓名">
        <a class="sch-btn" href="javascript:;" id="search" url="{:U('article/mydocument','pid='.I('pid',0).'&cate_id='.$cate_id,false)}"><i class="btn-search"></i></a>
    </div>
</div>
    <span>今日增加用户数：{$total.todaymembers}</span><br/>
    <span>本月增加用户数：{$total.monthmembers}</span><br/>
    <span>用户总数：{$total.members}</span>
    <div class="data-table table-striped">
        <form class="ids">
            <table>
                <thead>
                    <tr>
                        <th>昵称</th>
                        <th>手机号</th>
                        <th>性别</th>
                        <th>年龄</th>
                        <th>星座</th>
                        <th>是否认证</th>
                        <th>身份</th>
                        <th>举报次数</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
				<notempty name="data">
                <volist name="data" id="v">
                    <tr>
                        <td><a href="__CONTROLLER__/userdetails/id/{$v.id}">{$v.nickname}</a></td>
                        <td>{$v.mobile}</td>
                        <td>{$v.sex}</td>
                        <td>{$v.age}</td>
                        <td>{$v.constell}</td>
                        <!-- <td><eq name="v.attr" value="1">已认证<else/>未认证</eq></td> -->
						<!--yxf 20171108  -->
                        <td><if condition="$v.cfm eq 0">未认证<else/>已认证</if></td>
                        <td>{$v.identity}</td>
                        <td>{$v.report}</td>
                        <td>
							<a href="__CONTROLLER__/userdetails/id/{$v.id}">查看信息</a>
                            <a href="__MODULE__/Album/showAlbum/id/{$v.id}">相册</a>
                           <!--  <a href="__CONTROLLER__/updateUser/id/{$v.id}">详情</a> -->
                            <a class="oper" href="javascript:;" data="{$v.id}" val='2' flag="status">删除</a>
                            <eq name="v.pause" value="0">
                            <a class="oper" href="javascript:;" data="{$v.id}" val='1' flag="pause">暂停使用</a>
                            <else/>
                            <a class="oper" href="javascript:;" data="{$v.id}" val='0' flag="pause">开始使用</a>
                            </eq>
                        </td>
                    </tr>
                </volist>
				<else/>
				<td colspan="10" class="text-center"> aOh! 暂时还没有内容! </td>
				</notempty>
                </tbody>
            </table>
        </form>
        <!-- 分页 -->
        <div class="page">
            {$_page}
        </div>
    </div>
</block>
<block name="script">
    <script type="text/javascript">
        $(function() {
            $('.oper').click(function(){
                var mes = $(this).html();
                if (confirm('确定要'+mes+'吗？')) {
                    var id = $(this).attr('data');
                    var val = $(this).attr('val');
                    var flag = $(this).attr('flag');
                    $.post('__CONTROLLER__/edit', {'id': id,'val':val, 'flag':flag}, function(msg) {
                        alert(msg);
                        location.reload();
                    });
                }
            });
$("#search").click(function(){
        var str = $("#campus").val();
        var num = $('.drop-down span').html();
        var replaces = $('.drop-down span').html();
                switch(num)
                {
                case '昵称':
                    num = 'nickname';
                  break;
                case '手机号':
                    num = 'mobile';
                  break;
 }
				if(stripscript(str) == 0){
					alert("请输入查询内容");
					return false;
                }

        window.location.href="__CONTROLLER__/showUser/str/"+str+"/num/"+num+"/replaces/"+replaces;
    });
	/* 过滤特殊字符 */
	function stripscript(s)
	{
		var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]")
		var rs = "";
		for (var i = 0; i < s.length; i++) {
		rs = rs+s.substr(i, 1).replace(pattern, '');
		}
		return rs;
	}
    /* 状态搜索子菜单 */
    $(".search-form").find(".drop-down").hover(function(){
        $("#sub-sch-menu").removeClass("hidden");
    },function(){
        $("#sub-sch-menu").addClass("hidden");
    });
    $("#sub-sch-menu li").find("a").each(function(){
        $(this).click(function(){
            var text = $(this).text();
            $("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
            $("#sub-sch-menu").addClass("hidden");
        })
    });
    //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });
  });
    </script>
</block>